
*********Replication do file for "State Adoption of Tax Policy New Data and New Insights" APR 2014, Thomas J Hayes & Christopher Dennis

use "table 1 apr.dta"

*****FIGURE 1******
line top1 year if year > 1915 & year < 2003, by(state) ylabel( 0(25)50)


*********some tests for the cox model******
********************cox model********
***good examples on how to do this from STATA website http://www.stata.com/capabilities/survival-example-session/    *********

****sets the data for duration
stset durat, failure(adoptinc)

***runs the stcox model, do not include DV, just do stcox and then IVs
stcox incomerel urban fiscal elect1 elect2 previousa ideology demcont repcont top1 south

***dem pres vote instead of ideology (supplemental analysis)****
stcox incomerel urban fiscal elect1 elect2 previousa dempres demcont repcont top1 south

*****this test let's us konw if appropriate model is cox regression.  If any variables come out signficant, it may not be best model*****
stphtest, detail

****test equality of survivor functions
sts test adoptinc


*************************
*****Table 1*************
*************************

stset durat, failure(adoptinc)


***table 1***for Mac*****


stset durat, failure(adoptinc)


probit  adoptinc incomerel urban fiscal elect1 elect2 previousa ideology if year > 1915 & year < 1938

probit  adoptinc incomerel urban fiscal elect1 elect2 previousa  dempres demcont repcont top1 south durat if year > 1915 & year < 1938

probit adoptinc incomerel urban fiscal elect1 elect2 previousa dempres demcont repcont top1 south durat inc_top1 if year > 1915 & year < 1938

stcox incomerel urban fiscal elect1 elect2 previousa dempres demcont repcont top1 south if year > 1915 & year < 1938

stcox incomerel urban fiscal elect1 elect2 previousa dempres demcont repcont top1 south inc_top1 if year > 1915 & year < 1938


*****graphing interactions********for probit*****FIGURE 3

probit adoptinc incomerel urban fiscal elect1 elect2 previousa dempres demcont repcont top1 south durat inc_top1 if year > 1915 & year < 1938

margins, dydx(top1) at(incomerel=(.5(.25)1.25)) vsquish

margins, at(top1=(4 13) incomerel=(.5(.25)1.25)) vsquish

marginsplot, noci x(top1) recast(line) xlabel(4(2)13) scheme(s1mono)


*************************
*********Table 2*********
*************************

use  "deduct.gdp.5.2.13.dta"

gen durat = year-1960

gen fail = deduct

stset durat, failure(fail)

stset durat, failure(deduct)


******probit model
probit deduct bfnom bfcitizen pcinc elect1 elect2 top1 demcont repcont south gdp durat if year > 1959 & year < 2005
******probit interaction
probit deduct bfnom bfcitizen pcinc elect1 elect2 top1 demcont repcont south gdp durat top1_inc if year > 1959 & year < 2005
******cox proportional hazards model
stcox bfnom bfcitizen pcinc elect1 elect2 top1 demcont repcont south gdp if year > 1959 & year < 2005
****** cox proportional hazards model, with interaction
stcox bfnom bfcitizen pcinc elect1 elect2 top1 demcont repcont south gdp top1_inc if year > 1959 & year < 2005


***graphing interctions for probit (deduct)***FIGURE 5
probit deduct bfnom bfcitizen pcinc elect1 elect2 top1 demcont repcont south gdp durat top1_inc if year > 1959 & year < 2005

margins, dydx(top1) at(gdp=(1(5)20)) vsquish

margins, at(top1=(4 13) gdp=(1(5)20)) vsquish

marginsplot, noci x(top1) recast(line) xlabel(4(2)13) scheme(s1mono)


****************************
*****for appendix, results if we use pct neighbor (pct neighbor states) instead of previousa (total states)
****************************

use "apr.pctnbr.dta"

stset durat, failure(adoptinc)


probit  adoptinc incomerel urban fiscal elect1 elect2 pctnbr ideology  demcont repcont top1 south if year > 1915 & year < 1938

stcox incomerel urban fiscal elect1 elect2 pctnbr ideology demcont repcont south top1


************************************************************************
*******appendix for dropping outliers for top1 & substitute pct neighbor
**************************************************************************

gen topout=.
replace topout=top1 if top1 < 30
sum topout

probit adoptinc incomerel urban fiscal elect1 elect2 previousa dempres demcont repcont topout south if year > 1915 & year < 1938

stcox incomerel urban fiscal elect1 elect2 previousa dempres demcont repcont topout south if year > 1915 & year < 1938 



stcox incomerel urban fiscal elect1 elect2 previousa demcont repcont top1 south dempres if year > 1915 & year < 1938 & top1 < 31

stcox incomerel urban fiscal elect1 elect2 previousa demcont repcont top1 south dempres if year > 1915 & year < 1938 




******FIGURES 2 & 4 made using R, code is below but will only work with R program*****

library(foreign)
read.table
cd <- read.dta("BerryAJPSTop1Deduct.dta", convert.factors=TRUE)

library(car)
library(effects)

probit1 <- glm(adoptinc ~ incomerel + urban  + elect1 + elect2 + previousa + demcont + repcont + top1, family=binomial(link="probit"), data=cd, na.action=na.omit)
summary(probit1)

eff <- effect("top1", probit1)
print(plot(eff))



###table 1
##col 1
col1t1 <- glm(adoptinc ~ incomerel + urban + fiscal + elect1 + elect2 + previousa + ideology, family=binomial(link="probit"), data=cd, na.action=na.omit)
summary(col1t1)


##col 2
col2t1 <- glm(adoptinc ~ incomerel + urban + fiscal + elect1 + elect2 + previousa + demcont + repcont + top1, family=binomial(link="probit"), data=cd, na.action=na.omit)
summary(col2t1)

eff99 <- effect("top1", col2t1)
title(plot="Effect of Top 1 on Adoption of Income Tax", xlab="Percent Income for Top 1%", ylab="probability of adoption")
print(plot(eff99)) 
print(plot(eff99, rescale.axis=F))

plot(eff99, main=F, xlab = "Percent Income for Top 1%", rescale.axis=F,
  ylab = "Probability of Adopting Income Tax")



##col 3  
newcddata1 <- subset(cd, year >= 1916 & year <= 1928)

col3t1 <- glm(adoptinc ~ incomerel + urban + elect1 + elect2 + previousa + ideology, family=binomial(link="probit"), data=newcddata1)
summary(col3t1)

##col 4
col4t1 <- glm(adoptinc ~ incomerel + urban + fiscal + elect1 + elect2 + previousa + demcont + repcont + top1, family=binomial(link="probit"), data=newcddata1)
summary(col4t1)

eff <- effect("top1", col4t1)
title(plot="Effect of Top 1 on Adoption of Income Tax", xlab="Percent Income for Top 1%", ylab="probability of adoption")
print(plot(eff)) 
print(plot(eff, rescale.axis=F))

plot(eff, main=F, xlab = "Percent Income for Top 1%", rescale.axis=F,
  ylab = "Probability of Adoption")

